package com.ffcs.cn.action.base.treeTable;

import org.pushingpixels.substance.api.renderers.SubstanceDefaultTableCellRenderer;

import javax.swing.*;
import java.awt.*;

/**
  * 负责渲染第一列以外的所有列，这里区分了下2 3列使用了按钮控件去渲染，第4列使用了默认的Jlable去渲染
 */
public class DemoJTreeTableTableCellRender extends SubstanceDefaultTableCellRenderer {

	@Override
	public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
		JLabel tableCellRendererComponent = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
		if (value instanceof TreeTableNode) {
			TreeTableNode treeTableNode = (TreeTableNode) value;
			if (column < DialogJTreeTable.COLUMN_INDEX_TIME) {
				return treeTableNode.getRenderComponent(column);
			} else {
				tableCellRendererComponent.setText(treeTableNode.getTreeTableData().getTime());
				return tableCellRendererComponent;
			}
		}
		return tableCellRendererComponent;
	}

}
